Over time, databases have been gradually refined for improved performance. Small optimizations have accumulated to enable databases to perform efficiently and get the most out of available resources. When a query is executed by a database server or engine, there may be many different ways for the database server to perform the query. Some operations may be performed before others. Some tables might be queried before others. Joins might be performed in different orders or using different join methods. There may be different indices to choose from. To help a database server choose an optimal way of executing a query, cost models are often used. Cost models are statistical models that can be used to estimate execution costs for different query plans. Cost models have traditionally taken into account a number of parameters such as memory, distribution of values in the database, indices, historical workload statistics, and many others. Previously, database servers have not measured information about the number of distinct pages accessed for a query.
Discussed below are techniques related to efficiently computing distinct page counts using execution feedback, and using same to improve database performance.